package com.controller;

import com.entity.ums.Member;
import com.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("member")
public class MemberController {
    @Autowired
    private MemberService memberService;

    @GetMapping(value = "{id}")
    public Member getMember(@PathVariable Integer id) {
        return memberService.getMemberById(id);
    }
    @GetMapping(value = "address/{id}")
    public Member getMemberAndAddressByMemberId(@PathVariable Integer id) {
        return memberService.getMemberAndAddressByMemberId(id);
    }

    @GetMapping("/update")
    public int update(@RequestParam("id") Integer id, @RequestParam("phone") String phone) {
        return memberService.updateMember(phone, id);
    }
}
